package tech.jabari.user.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.jabari.user.entity.User;

import java.util.List;
import java.util.Map;

public interface UserMapper {

    @Insert("insert into t_user(username,pwd,email,phone,sex,birth,headImg) values" +
            "(#{username} , #{pwd} , #{email} , #{phone} , #{sex} , #{birthStr} , #{headImg} )")
    Integer insertUser(User user);

    int deleteByPrimaryKey(Integer id);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    List<User> findAllUser(Map<String, Object> paramsMap);

    Long findAllUserCount(Map<String, Object> paramsMap);

    @Select("select * from t_user where username=#{username} and pwd=#{pwd}")
    List<User> selectUserByUsernameAndPwd(@Param("username") String username,
                                          @Param("pwd") String pwd);

    @Select("select * from t_user where username=#{username}")
    List<User> selectUserByUsername(@Param("username") String username);


    @Update("update t_user set username = #{username} ,pwd = #{pwd} ,email=#{email} ," +
            "phone=#{phone} ,sex=#{sex} ,birth=#{birthStr} ," +
            "headImg=#{headImg}  where id = #{id} ")
    Integer updateUser(User user);
}
